package com.lyq.mr.wc;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class WordcountReducer extends Reducer<Text,LongWritable,Text,LongWritable> {

    LongWritable num =new LongWritable();

    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {
        int count=0;

        for (LongWritable value : values) {
            count +=value.get();
        }
        num.set(count);

        context.write(key,num);


    }
}
